{% extends "base.html" %}
{% load cms_tags %}
{% load i18n %}

{% block base_content %}
  	<div class="container">
	{% include "component/event/event-breadcrumb-result.html" %}
		<div class="row">
			<div class="col-md-12">
				<!-- content -->
				<div class="page-header">
					<h3 class="text-info">{{ event.name }}</h3>
				</div>
			</div>
		</div>
		{% include "component/event/event-info-result.html" %}
		<!-- event specific description -->
		<div class="page-header">
		</div>
		<div class="row">
			<div class="col-md-12">
				<h3 class="text-info">{% trans "Records" %}</h3>
			</div>
		</div>
		<div class="row">
				{% if rankList|length %}
				<div class="col-md-6">
					<table class="table table-hover table-condensed">
						<thead><tr>
							<td>{% trans "Name" %}</td>
							<td>{% trans "Serial" %}</td>
							<td>{% trans "Rank" %}</td>
							<td>{% trans "Record" %}</td>
						</tr></thead>
						<tbody>
						{% for result in rankList %}
							<tr>
							<td name="result_name">{{result.name}}</td>
							<td name="result_serial">{% if result.serial != None %}{{result.serial}}{% endif %}</td>
							<td name="result_totalRank">{{result.totalRank}}</td>
							<td name="result_record">{{result.record}}</td>
							</tr>
						{% endfor %}
						{% for result in dnfList %}
							<tr>
							<td name="result_name">{{result.name}}</td>
							<td name="result_serial"></td>
							<td name="result_totalRank">--</td>
							<td name="result_record-dnf">DNF/DNS</td>
							</tr>
						{% endfor %}
						</tbody>
						<script type="text/javascript">
							$('td[name=result_record]').each( function (index, element) {
								var val, sec, min;
								val = parseInt($(element).text());
								if( isNaN(val) ) return;
								
								min = Math.round(val / 60);
								sec = val % 60;
								$(element).html(""+min+ '<sub>{% trans "min "%}</sub>'+sec+ '<sub>{% trans "sec "%}</sub>');
							});
						</script>
					</table>
				</div>
				{% else %}
				<div class="col-md-12">
					<h4 class="text-muted"><i class="fa fa-warning"></i> {% trans "Records are not published yet." %}
				</div>
				{% endif %}
		</div>
	</div>
{% endblock %}